package com.example.chinesechess;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class TestView extends View {

    private String redText;  
    private int value;  
  
    //a paint object to render the redText  
    private Paint paint;  
  
    public TestView(Context context, AttributeSet attrs)  
    {  
        super(context, attrs);  
  
        //initialize the paint object  
        paint = new Paint();  
        //set the color to red  
        paint.setColor(Color.RED);  
  
        //initialize the redText String with the attribute with the same name at the XML file  
        redText = attrs.getAttributeValue(null, "redText");  
        //initialize the value integer with the attribute with the same name at the XML file  
        value = attrs.getAttributeIntValue(null, "value", 0);  
    }  
    
    
    public void someCall() {
    	this.setBackgroundColor(Color.GREEN);
    }
    
    @Override  
    protected void onDraw(Canvas canvas)  
    {  
        super.onDraw(canvas);  
  
        //render the redText at the specified position  
        canvas.drawText(""+this.getWidth()+","+this.getHeight(), 10, 100, paint);  
  
        //render the integer variable value  
        canvas.drawText("Value: " + Integer.toString(value), 10, 140, paint);  
    }  
}
